package com.qingmeng.portal.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.*;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spi.service.contexts.SecurityContext;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

import java.util.ArrayList;
import java.util.List;
/**
 * Swagger2API文档的配置
 */
@Configuration//配置类
@EnableSwagger2//开启swagger2的功能,开发和测试的时候才会用到，项目上线后就不需要了
public class Swagger2Config {
    @Bean
    public Docket createRestApi(){
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo())
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.qingmeng.portal.controller"))
                .paths(PathSelectors.any())
                .build();
    }
    private ApiInfo apiInfo(){
        return new ApiInfoBuilder()
                .title("测试Swagger文档接口")
                .description("spring-swaggeer后台接口文档")
                /*.contact(new Contact("spring-swagger",
                       "https://www.qingmengtech.com",
                       "test@163.com"))
                .version("1.1")*/
                .build();
    }
}
